<?php
/* -=-=-=-=-=-=-=-=-=-=-=-=-
     author by terry
-=-=-=-=-=-=-=-=-=-=-=-=- */
error_reporting(7);
require "global.php";

//change status
if($_GET[changeid]!=''){
   $sql = "UPDATE pa_employer SET `ep_status`='".$_GET[changeid]."'  WHERE ep_id ='".$_GET[id]."' ";
   $DB->query($sql);
   $_GET[action]="list";
}

cpheader();
//set offset
if(!empty($_POST[offset]))
{$offset = $_POST[offset];}
else if  (!empty($_GET[offset]))
{$offset = $_GET[offset]; }
else  {$offset = 0; }


if ($_GET[action]=="add"||$_GET[action]=='mod'||$_GET[action]=='view'){

    $cpforms->inithtmlarea();
	if($_GET[action]=="add"){
			$cpforms->formheader(array('title'=>'Add New Employer (<font color=red>*</font>=Required Field)',
										'name'=>'article'));

			$cpforms->makehidden(array('name'=>'action',
									   'value'=>'doinsert'));
			$rs[StartDate] = $rs[EndDate] = time();
	}
	if($_GET[action] == "mod"){
			$cpforms->formheader(array('title'=>'Modify Employer (<font color=red>*</font>=Required Field)',
										'name'=>'article'));

			$cpforms->makehidden(array('name'=>'action',
									   'value'=>'update'));
		    $employerid = intval($_GET[id]);
			$cpforms->makehidden(array('name'=>'id',
									   'value'=>$employerid));
			$cpforms->makehidden(array('name'=>'offset',
									   'value'=>$offset));
            $read =1;
	        $rs  = $DB->fetch_one_array("SELECT * FROM ".$db_prefix."employer WHERE ep_id =".$employerid);
	}

	if($_GET[action]=="view"){
				$cpforms->formheader(array('title'=>'View Employer (<font color=red>*</font>=Required Field)',
										'name'=>'article',
				                        'enctype'=>'multipart/form-data'));
		    $employerid = intval($_GET[id]);
			$cpforms->makehidden(array('name'=>'id',
									   'value'=>$employerid));
			$cpforms->makehidden(array('name'=>'offset',
									   'value'=>$offset));
            $view =1;
	        $rs  = $DB->fetch_one_array("SELECT * FROM ".$db_prefix."employer WHERE ep_id =".$employerid);
	}

	
	?>
     <?       
	       $cpforms->gethightext(array('text'=>"√Username",'name'=>"user_name",'only'=>1,'value'=>"$rs[ep_uname]",'read'=>"$read",'view'=>"$view",'icon'=>"'Username is 6-12 Characters and is Case Sensitive.', WIDTH, 200, SHADOW, true"));
	       $cpforms->gethightext(array('text'=>"Password",'name'=>"password",'type'=>"password",'only'=>1,'view'=>"$view",'icon'=>"'Password is 6-12 Characters and is Case Sensitive.', WIDTH, 200, SHADOW, true"));
		   $cpforms->longline(array('title'=>"Contact Information"));
		   $cpforms->gethightext(array('text'=>"Your First Name",'name'=>"firstname",'only'=>1,'value'=>"$rs[ep_fname]",'view'=>"$view"));
		   $cpforms->gethightext(array('text'=>"Your Last Name", 'name'=>"lastname",'only'=>1,'value'=>"$rs[ep_lname]",'view'=>"$view"));
           $cpforms->gethightext(array('text'=>"Your Email Address", 'name'=>"email",'only'=>1,'value'=>"$rs[ep_email]",'view'=>"$view"));
		   $cpforms->gethightext(array('text'=>"Your Phone", 'name'=>"phone",'only'=>1,'value'=>"$rs[ep_phone]",'view'=>"$view"));
		   $cpforms->gethightext(array('text'=>"Your Fax", 'name'=>"fax",'value'=>"$rs[ep_fax]",'view'=>"$view"));
		   $cpforms->gethightext(array('text'=>"Your Job Title", 'name'=>"jobtitle",'only'=>1,'value'=>"$rs[ep_title]",'view'=>"$view"));
		   $cpforms->gethightext(array('text'=>"Your Skype ID", 'name'=>"skype",'value'=>"$rs[ep_skype]",'view'=>"$view",'icon'=>"' If you do not have a Skype ID, you may complete this field later.  To get FREE Skype, <a href=\'http://www.skype.com/download\'>Go Here</a>', WIDTH, 200, TITLE,'', SHADOW, true, FADEIN, 100, FADEOUT, 100, STICKY, 1,  CLOSEBTN, true, CLICKCLOSE, true"));
		   $cpforms->gethighradio(array('text'=>"Would you like to subscribe to our newsletter",'name'=>"newsmailist",'only'=>1,'selected'=>"$rs[ep_newsmailist]",'view'=>"$view"));
		   $cpforms->gethightext(array('text'=>"How did you hear about us?",'name'=>"howus",'only'=>1,'value'=>"$rs[ep_howus]",'view'=>"$view"));
		   $cpforms->gethightext(array('text'=>"Service Code", 'name'=>"servicecode",'value'=>"$rs[ep_servicecode]",'view'=>"$view",'icon'=>"'If you have a service code please enter it here.', WIDTH, 200, SHADOW, true"));
		   
		   
		   $cpforms->longline(array('title'=>"Company Information"));
		   $cpforms->gethightext(array('text'=>"Company Name", 'name'=>"companyname",'only'=>1,'value'=>"$rs[ep_copname]",'view'=>"$view"));
		   $cpforms->gethightext(array('text'=>"Company Website URL",'name'=>"companyurl",'only'=>1,'value'=>"$rs[ep_website]",'view'=>"$view"));
		   $cpforms->makeselect(array('text'=>"√Industry", 'name'=>"industry",'only'=>1,'option'=>$jobcategory,'selected'=>"$rs[ep_industry]",'view'=>"$view",'viewfunction'=>'jobcategory'));
		   $cpforms->gethightext(array('text'=>"√Company Size", 'name'=>"companysize",'only'=>1,'value'=>"$rs[ep_copsize]",'view'=>"$view",'icon'=>"' Enter an estimated number of full time employees.', WIDTH, 300, SHADOW, true"));
		   $cpforms->gethightext(array('text'=>"Address",'name'=>"address",'only'=>1,'value'=>"$rs[ep_address1]",'view'=>"$view"));
		   $cpforms->gethightext(array('text'=>"√Location - City",'name'=>"locity",'only'=>1,'value'=>"$rs[ep_city]",'view'=>"$view"));
		   $cpforms->makeselect(array('text'=>"√Location - State", 'name'=>"lostate",'only'=>1,'option'=>$state,'selected'=>"$rs[ep_state]",'view'=>"$view",'viewfunction'=>'state'));
		   $cpforms->gethightext(array('text'=>"√Location - Zip Code",'name'=>"lozip",'only'=>1,'value'=>"$rs[ep_zip]",'view'=>"$view"));
		   $cpforms->makeselect(array('text'=>"√Location - Country",'name'=>"locountry",'only'=>1,'option'=>$country,'selected'=>"$rs[ep_country]",'view'=>"$view",'viewfunction'=>'country'));
		   $cpforms->gethightext(array('text'=>"ER Account Manager",'name'=>"eraccount",'value'=>"$rs[ep_ERaccount]",'view'=>"$view",'icon'=>"'Enter the name of your enetRecruiter account manager.', WIDTH, 300, SHADOW, true"));
		   $cpforms->maketextarea(array('text'=>"Company Culture",'name'=>"culture",'value'=>"$rs[ep_CompCulture]",'view'=>"$view",'icon'=>"'Please describe in 500 characters or less.  You may edit this later.', WIDTH, 300, SHADOW, true"));
		   $cpforms->maketextarea(array('text'=>"Company Benefits",'name'=>"benefits",'value'=>"$rs[ep_CompBenefits]",'view'=>"$view",'icon'=>"'Please describe in 500 characters or less.  You may edit this later.', WIDTH, 300, SHADOW, true"));
		   $cpforms->longline(array('title'=>"Billing Information (Complete only if different from the information above)"));
		   
           $cpforms->gethightext(array('text'=>"Contact Name for Billing",'name'=>"bname",'value'=>"$rs[ep_bname]",'view'=>"$view"));
           $cpforms->gethightext(array('text'=>"Contact Email for Billing",'name'=>"bemail",'value'=>"$rs[ep_bemail]",'view'=>"$view"));
		   $cpforms->gethightext(array('text'=>"Contact Phone for Billing",'name'=>"bphone",'value'=>"$rs[ep_bphone]",'view'=>"$view"));
		   $cpforms->gethightext(array('text'=>"Billing Address",'name'=>"baddress",'value'=>"$rs[ep_baddress]",'view'=>"$view"));

		   $cpforms->longline(array('title'=>"Business Entity Information"));
		   $cpforms->gethightext(array('text'=>"Business License Number",'name'=>"licensenumber",'value'=>"$rs[ep_license]",'view'=>"$view",'icon'=>"'Please Business License Number. ', WIDTH, 300, SHADOW, true"));
		   $cpforms->gethightext(array('text'=>"Business License Issuing City, State, Country",'name'=>"licenseissue",'value'=>"$rs[ep_license_Issue]",'view'=>"$view",'icon'=>"'Please enter the city, state and country in which your business license was issued.', WIDTH, 300, SHADOW, true"));
		   $cpforms->gethightext(array('text'=>"Federal Tax ID#",'name'=>"licensephone",'value'=>"$rs[ep_license_office]",'view'=>"$view",'icon'=>"'Please enter your Federal Tax ID#.', WIDTH, 300, SHADOW, true"));
		   $cpforms->longline(array('title'=>"Professional Reference"));
		   $cpforms->smallline(array('title'=>"1st Reference"));
           $cpforms->gethightext(array('text'=>"Company Name",'name'=>"ref_1_cpname",'value'=>"$rs[ep_pr1_cpname]",'view'=>"$view"));
           $cpforms->gethightext(array('text'=>"Contact Name",'name'=>"ref_1_ctname",'value'=>"$rs[ep_pr1_ctname]",'view'=>"$view"));
           $cpforms->gethightext(array('text'=>"Phone",'name'=>"ref_1_phone",'value'=>"$rs[ep_pr1_phone]",'view'=>"$view"));
           $cpforms->gethightext(array('text'=>"Email",'name'=>"ref_1_email",'value'=>"$rs[ep_pr1_email]",'view'=>"$view"));
           $cpforms->gethightext(array('text'=>"Relationship",'name'=>"ref_1_relationship",'value'=>"$rs[ep_pr1_relationship]",'view'=>"$view"));
		   $cpforms->smallline(array('title'=>"2nd Reference"));
           $cpforms->gethightext(array('text'=>"Company Name",'name'=>"ref_2_cpname",'value'=>"$rs[ep_pr2_cpname]",'view'=>"$view"));
           $cpforms->gethightext(array('text'=>"Contact Name",'name'=>"ref_2_ctname",'value'=>"$rs[ep_pr2_ctname]",'view'=>"$view"));
           $cpforms->gethightext(array('text'=>"Phone",'name'=>"ref_2_phone",'value'=>"$rs[ep_pr2_phone]",'view'=>"$view"));
           $cpforms->gethightext(array('text'=>"Email",'name'=>"ref_2_email",'value'=>"$rs[ep_pr2_email]",'view'=>"$view"));
           $cpforms->gethightext(array('text'=>"Relationship",'name'=>"ref_2_relationship",'value'=>"$rs[ep_pr2_relationship]",'view'=>"$view"));
		   $cpforms->smallline(array('title'=>"3rd Reference"));
           $cpforms->gethightext(array('text'=>"Company Name",'name'=>"ref_3_cpname",'value'=>"$rs[ep_pr3_cpname]",'view'=>"$view"));
           $cpforms->gethightext(array('text'=>"Contact Name",'name'=>"ref_3_ctname",'value'=>"$rs[ep_pr3_ctname]",'view'=>"$view"));
           $cpforms->gethightext(array('text'=>"Phone",'name'=>"ref_3_phone",'value'=>"$rs[ep_pr3_phone]",'view'=>"$view"));
           $cpforms->gethightext(array('text'=>"Email",'name'=>"ref_3_email",'value'=>"$rs[ep_pr3_email]",'view'=>"$view"));
           $cpforms->gethightext(array('text'=>"Relationship",'name'=>"ref_3_relationship",'value'=>"$rs[ep_pr3_relationship]",'view'=>"$view"));
	
	 ?>

<?

   if($_GET[action]=="view"){$cpforms->noformfooter();}
	   else{ $cpforms->formfooter(array('confirm'=>1));}
}


if ($_GET[action]=="list"){


	if($_GET[action]=="list"){   
		$nav = new buildNav;

		$total = $DB->fetch_one_array("SELECT COUNT(*) AS count FROM ".$db_prefix."employer");

		$nav->total_result = $total[count];

		if (empty($total[count])) {
			pa_exit("<font color=red>No employer!</font><input type=button value='Add New' onclick='location.href=\"employer.php?action=add\"'>");
		}
		$by = "ep_id"; 
		$order = "DESC";
        $_GET[order1]==''&&$order1=1;$_GET[order2]==''&&$order2=1;$_GET[order3]==''&&$order3=1;$_GET[order4]==''&&$order4=1;
		$_GET[order5]==''&&$order5=1;$_GET[order6]==''&&$order6=1;$_GET[order7]==''&&$order7=1;$_GET[order8]==''&&$order8=1;
		switch($_GET[swh]){
		   case 1:
			   $by = "ep_copname";
               if($_GET[order1]==1){$order1=2; $order=" DESC ";$image1 = "<img src=\"images/dot1.gif\">";}else{$order1=1;$order=" ASC ";$image1 = "<img src=\"images/dot2.gif\">";}
			   break;
           case 2:
               $by = "ep_uname";
               if($_GET[order2]==1){$order2=2; $order=" DESC ";$image2 = "<img src=\"images/dot1.gif\">";}else{$order2=1;$order=" ASC ";$image2 = "<img src=\"images/dot2.gif\">";}
			   break;
		   case 3:
                $by = "ep_fname";
               if($_GET[order3]==1){$order3=2; $order=" DESC ";$image3 = "<img src=\"images/dot1.gif\">";}else{$order3=1;$order=" ASC ";$image3 = "<img src=\"images/dot2.gif\">";}
			   break;
		   case 4:
               $by = "ep_lname";
               if($_GET[order4]==1){$order4=2; $order=" DESC ";$image4 = "<img src=\"images/dot1.gif\">";}else{$order4=1;$order=" ASC ";$image4 = "<img src=\"images/dot2.gif\">";}
			   break;
			case 5:
			   $by = "ep_industry";
               if($_GET[order5]==1){$order5=2; $order=" DESC ";$image5 = "<img src=\"images/dot1.gif\">";}else{$order5=1;$order=" ASC ";$image5 = "<img src=\"images/dot2.gif\">";}
			   break;
           case 6:
               $by = "ep_city";
               if($_GET[order6]==1){$order6=2; $order=" DESC ";$image6 = "<img src=\"images/dot1.gif\">";}else{$order6=1;$order=" ASC ";$image6 = "<img src=\"images/dot2.gif\">";}
			   break;
		   case 7:
                $by = "ep_state";
               if($_GET[order7]==1){$order7=2; $order=" DESC ";$image7 = "<img src=\"images/dot1.gif\">";}else{$order7=1;$order=" ASC ";$image7 = "<img src=\"images/dot2.gif\">";}
			   break;
		   case 8:
               $by = "ep_country";
               if($_GET[order8]==1){$order8=2; $order=" DESC ";$image8 = "<img src=\"images/dot1.gif\">";}else{$order8=1;$order=" ASC ";$image8 = "<img src=\"images/dot2.gif\">";}
			   break;	
		  case 9:
               $by = "ep_newsmailist";
               if($_GET[order9]==1){$order9=2; $order=" DESC ";$image9 = "<img src=\"images/dot1.gif\">";}else{$order9=1;$order=" ASC ";$image9 = "<img src=\"images/dot2.gif\">";}
			   break;	
		case 10:
               $by = "ep_regtime";
               if($_GET[order10]==1){$order10=2; $order=" DESC ";$image10 = "<img src=\"images/dot1.gif\">";}else{$order10=1;$order=" ASC ";$image10 = "<img src=\"images/dot2.gif\">";}
			   break;	
        case 11:
               $by = "ep_status";
               if($_GET[order11]==1){$order11=2; $order=" DESC ";$image11 = "<img src=\"images/dot1.gif\">";}else{$order11=1;$order=" ASC ";$image11 = "<img src=\"images/dot2.gif\">";}
			   break;	
		}
		
		$order = " ORDER BY $by $order";
		$nav->execute("SELECT * FROM ".$db_prefix."employer $order");

    }
	
	echo $nav->title("Employer list");
    echo $nav->pagenav();

    echo "<table border=\"0\" width=\"100%\" cellpadding=\"4\" cellspacing=\"1\" class=\"tableoutline\">
	<script type=\"text/javascript\" src=\"http://download.skype.com/share/skypebuttons/js/skypeCheck.js\"></script>
	           <tr><td colspan=7><input type=button value=\"Add New Employer\" onclick=\"location.href='employer.php?action=add'\"></td></tr>
               <tr align=\"center\" class=\"tbhead\">
                <td nowrap  width=\"6%\"><a href=\"employer.php?action=list&offset=$_GET[offset]&order1=$order1&swh=1\">$image1 Company </a></td>
                <td nowrap  width=\"10%\"><a href=\"employer.php?action=list&offset=$_GET[offset]&order2=$order2&swh=2\">$image2 Username </a></td>
                <td nowrap  width=\"10%\">Service code</td>
                <td nowrap  width=\"30%\"><a href=\"employer.php?action=list&offset=$_GET[offset]&order3=$order3&swh=3\">$image3 First Name </a></td>
				 <td nowrap  width=\"2%\"><a href=\"employer.php?action=list&offset=$_GET[offset]&order4=$order4&swh=4\">$image4 Last Name </a></td>
				 <td nowrap  width=\"10%\"> Email </td>
				 <td nowrap  width=\"18%\"> Phone </td>
				<td nowrap  width=\"6%\"><a href=\"employer.php?action=list&offset=$_GET[offset]&order5=$order5&swh=5\">$image5 Industry </a></td>
                <td nowrap  width=\"10%\"><a href=\"employer.php?action=list&offset=$_GET[offset]&order6=$order6&swh=6\">$image6 City </a></td>
                <td nowrap  width=\"30%\"><a href=\"employer.php?action=list&offset=$_GET[offset]&order7=$order7&swh=7\">$image7 State </a></td>
				 <td nowrap  width=\"2%\"><a href=\"employer.php?action=list&offset=$_GET[offset]&order8=$order8&swh=8\">$image8 Country </a></td>
				<td nowrap  width=\"10%\"><a href=\"employer.php?action=list&offset=$_GET[offset]&order9=$order9&swh=9\">$image9 Newsletter </a></td>
                <td nowrap  width=\"10%\"><a href=\"employer.php?action=list&offset=$_GET[offset]&order10=$order10&swh=10\">$image10 Register Date </a></td>
				<td nowrap  width=\"10%\"><a href=\"employer.php?action=list&offset=$_GET[offset]&order11=$order10&swh=11\">$image11  Status</a></td> 
				 <td nowrap  width=\"10%\"> Action </td>
               </tr>\n";
    while ($list = $DB->fetch_array($nav->sql_result)){
		if($list[ep_newsmailist]==1){$newslist = "Yes" ;}else{$newslist = "No" ;}
           echo "<tr class=".getrowbg().">
                      <td align=\"left\" nowrap>".$list[ep_copname]."</td>
                      <td align=\"left\">".$list[ep_uname]."</td>
                      <td align=\"left\">".$list[ep_servicecode]."</td>
					  <td align=\"left\">".$list[ep_fname]."</td>
					  <td align=\"left\">".$list[ep_lname]."</td>
					  <td align=\"left\">".$list[ep_email]."</td>
					  <td align=\"left\">".$list[ep_phone]."</td>
					  <td align=\"left\">".$jobcategory[$list[ep_industry]]."</td>
					  <td align=\"left\">".$list[ep_city]."</td>
					  <td align=\"left\">".$state[$list[ep_state]]."</td>
					  <td align=\"left\">".$country[$list[ep_country]]."</td>
					  <td align=\"left\">".$newslist."</td>
					  <td align=\"left\">".date('m/d/Y',$list[ep_regtime])."</td>
					  <td align=\"left\"><select name=\"status\" onchange=\"changestatus('employer.php','".$list[ep_id]."',this.options[this.options.selectedIndex].value)\">
						  <option value='0' ";
					if($list[ep_status]==0) echo " selected ";
			              echo ">Starter</option>
						  <option value='1' ";
					if($list[ep_status]==1) echo " selected ";
			              echo ">Active</option>
						  <option value='2' ";
					if($list[ep_status]==2) echo " selected ";
			              echo ">Expired</option></select></td>
                      <td align=\"left\" nowrap><a href=\"employer.php?action=view&offset=$_GET[offset]&id=$list[ep_id]\">View</a> | <a href=\"employer.php?action=mod&offset=$_GET[offset]&id=$list[ep_id]\">Edit</a> | <a href=\"employer.php?action=kill&offset=$_GET[offset]&id=$list[ep_id]\">Delete</a>";
    }
	if(empty($total[count])){
			echo "<tr><td><font color=red>No results!</font></td></tr>";
   }
    echo "</table>\n";
    echo $nav->pagenav();
}

if ($_GET[action]=="kill"){
    $cpforms->formheader(array('title'=>'Sure to delete this?'));
    $cpforms->makehidden(array('name'=>'action',
                                'value'=>'remove'));
    $cpforms->makehidden(array('name'=>'employerid',
                                'value'=>$_GET[id]));
	$cpforms->makehidden(array('name'=>'offset',
                                'value'=>$_GET[offset]));
    $cpforms->formfooter(array('confirm'=>2));
}


if( $_POST[action]=="remove"){
    $DB->query("DELETE FROM ".$db_prefix."employer WHERE ep_id='$_POST[employerid]'");
    redirect("./employer.php?action=list&offset=".$offset,"<font color=red>Deleted Successfully!</font>");
}



if ($_POST[action]=="doinsert"){
	
    $username       = htmlspecialchars(trim($_POST[user_name]));
	$password       = md5(trim($_POST[password]));
	$firstname      = htmlspecialchars(trim($_POST[firstname]));
	$lastname       = htmlspecialchars(trim($_POST[lastname]));
	$email          = htmlspecialchars(trim($_POST[email]));
	$phone          = htmlspecialchars(trim($_POST[phone]));
	$fax            = htmlspecialchars(trim($_POST[fax]));
	$jobtitle       = htmlspecialchars(trim($_POST[jobtitle]));
	$skype          = htmlspecialchars(trim($_POST[skype]));
	$newsmailist    = htmlspecialchars(trim($_POST[newsmailist]));
	$howus          = htmlspecialchars(trim($_POST[howus]));
	$servicecode    = htmlspecialchars(trim($_POST[servicecode]));
    $companyname    = htmlspecialchars(trim($_POST[companyname]));
	$companyurl     = htmlspecialchars(trim($_POST[companyurl]));
	$industry       = htmlspecialchars(trim($_POST[industry]));
	$companysize    = htmlspecialchars(trim($_POST[companysize]));
	$address        = htmlspecialchars(trim($_POST[address]));
	$locity         = htmlspecialchars(trim($_POST[locity]));
	$lostate        = htmlspecialchars(trim($_POST[lostate]));
	$lozip          = htmlspecialchars(trim($_POST[lozip]));
	$locountry      = htmlspecialchars(trim($_POST[locountry]));
	$eraccount      = htmlspecialchars(trim($_POST[eraccount]));
	$culture        = htmlspecialchars(trim($_POST[culture]));
	$benefits       = htmlspecialchars(trim($_POST[benefits]));
	$bname          = htmlspecialchars(trim($_POST[bname]));
	$bemail         = htmlspecialchars(trim($_POST[bemail]));
	$bphone         = htmlspecialchars(trim($_POST[bphone]));
	$baddress       = htmlspecialchars(trim($_POST[baddress]));
	$licensenumber  = htmlspecialchars(trim($_POST[licensenumber]));
	$licenseissue   = htmlspecialchars(trim($_POST[licenseissue]));
	$licensephone   = htmlspecialchars(trim($_POST[licensephone]));
	$ref_1_cpname   = htmlspecialchars(trim($_POST[ref_1_cpname]));
	$ref_2_cpname   = htmlspecialchars(trim($_POST[ref_2_cpname]));
	$ref_3_cpname   = htmlspecialchars(trim($_POST[ref_3_cpname]));
	$ref_1_ctname   = htmlspecialchars(trim($_POST[ref_1_ctname]));
	$ref_2_ctname   = htmlspecialchars(trim($_POST[ref_2_ctname]));
	$ref_3_ctname   = htmlspecialchars(trim($_POST[ref_3_ctname]));
	$ref_1_phone    = htmlspecialchars(trim($_POST[ref_1_phone]));
	$ref_2_phone    = htmlspecialchars(trim($_POST[ref_2_phone]));
	$ref_3_phone    = htmlspecialchars(trim($_POST[ref_3_phone]));
	$ref_1_email    = htmlspecialchars(trim($_POST[ref_1_email]));
	$ref_2_email    = htmlspecialchars(trim($_POST[ref_2_email]));
	$ref_3_email    = htmlspecialchars(trim($_POST[ref_3_email]));
	$ref_1_relationship    = htmlspecialchars(trim($_POST[ref_1_relationship]));
	$ref_2_relationship    = htmlspecialchars(trim($_POST[ref_2_relationship]));
	$ref_3_relationship    = htmlspecialchars(trim($_POST[ref_3_relationship]));

 	$sql_1  = " select ep_uname,ep_pword from pa_employer where ep_uname = '".$username."' ";
	$arr1 = $DB->fetch_one_array($sql_1);
	$sql_2  = " select js_uname,js_pword from pa_candidates where js_uname ='".$username."'";
	$arr2 = $DB->fetch_one_array($sql_2);
	$sql_3  = " select rc_uname,rc_pword from pa_recuiter where rc_uname ='".$username."'";
	$arr3 = $DB->fetch_one_array($sql_3);
    $sql_4  = " select ad_uname,ad_pword from pa_advisory where ad_uname ='".$username."'";
	$arr4 = $DB->fetch_one_array($sql_4);

    $deadline = $deadline_conf + time();
	if(empty($arr1)&&empty($arr2)&&empty($arr3)&&empty($arr4)){
		  $sql = "INSERT INTO `pa_employer` (`ep_servicecode`, `ep_uname`, `ep_pword`, `ep_copname`, `ep_fname`, `ep_lname`, `ep_title`, `ep_address1`, `ep_industry`, `ep_copsize`, `ep_skype`, `ep_country`, `ep_state`, `ep_city`, `ep_zip`, `ep_phone`, `ep_fax`, `ep_email`, `ep_website`, `ep_howus`, `ep_newsmailist`, `ep_bname`, `ep_bemail`, `ep_bphone`, `ep_baddress`, `ep_regtime`, `ep_deadline`, `ep_status`, `ep_ERaccount`, `ep_CompCulture`, `ep_CompBenefits`, `ep_license`, `ep_license_Issue`, `ep_license_office`, `ep_pr1_cpname`, `ep_pr1_ctname`, `ep_pr1_phone`, `ep_pr1_email`, `ep_pr1_relationship`, `ep_pr2_cpname`, `ep_pr2_ctname`, `ep_pr2_phone`, `ep_pr2_email`, `ep_pr2_relationship`, `ep_pr3_cpname`, `ep_pr3_ctname`, `ep_pr3_phone`, `ep_pr3_email`, `ep_pr3_relationship`) 
		  VALUES ('".$servicecode."', '".$username."', '".$password."', '".$companyname."', '".$firstname."', '".$lastname."', '".$jobtitle."', '".$address."', '".$industry."', '".$companysize."', '".$skype."', '".$locountry."', '".$lostate."', '".$locity."', '".$lozip."', '".$phone."', '".$fax."', '".$email."', '".$companyurl."', '".$howus."', '".$newsmailist."', '".$bname."', '".$bemail."', '".$bphone."', '".$baddress."', '".time()."', '".$deadline."', '0', '".$eraccount."', '".$culture."', '".$benefits."', '".$licensenumber."', '".$licenseissue."', '".$licensephone."', '".$ref_1_cpname."', '".$ref_1_ctname."', '".$ref_1_phone."', '".$ref_1_email."', '".$ref_1_relationship."', '".$ref_2_cpname."', '".$ref_2_ctname."', '".$ref_2_phone."', '".$ref_2_email."', '".$ref_2_relationship."', '".$ref_3_cpname."', '".$ref_3_ctname."', '".$ref_3_phone."', '".$ref_3_email."', '".$ref_3_relationship."');";


			$DB->query($sql);
	}else{
	  pa_exit("<h3 style=\"color:red\">The username is already taken. Please choose another one.</h3>");
	}
    redirect("./employer.php?action=list","<font color=red>Added Successfully!</font>");
}


if ($_POST[action]=="update"){

	$password       = md5(trim($_POST[password]));
	$firstname      = htmlspecialchars(trim($_POST[firstname]));
	$lastname       = htmlspecialchars(trim($_POST[lastname]));
	$email          = htmlspecialchars(trim($_POST[email]));
	$phone          = htmlspecialchars(trim($_POST[phone]));
	$fax            = htmlspecialchars(trim($_POST[fax]));
	$jobtitle       = htmlspecialchars(trim($_POST[jobtitle]));
	$skype          = htmlspecialchars(trim($_POST[skype]));
	$newsmailist    = htmlspecialchars(trim($_POST[newsmailist]));
	$howus          = htmlspecialchars(trim($_POST[howus]));
	$servicecode    = htmlspecialchars(trim($_POST[servicecode]));
    $companyname    = htmlspecialchars(trim($_POST[companyname]));
	$companyurl     = htmlspecialchars(trim($_POST[companyurl]));
	$industry       = htmlspecialchars(trim($_POST[industry]));
	$companysize    = htmlspecialchars(trim($_POST[companysize]));
	$address        = htmlspecialchars(trim($_POST[address]));
	$locity         = htmlspecialchars(trim($_POST[locity]));
	$lostate        = htmlspecialchars(trim($_POST[lostate]));
	$lozip          = htmlspecialchars(trim($_POST[lozip]));
	$locountry      = htmlspecialchars(trim($_POST[locountry]));
	$eraccount      = htmlspecialchars(trim($_POST[eraccount]));
	$culture        = htmlspecialchars(trim($_POST[culture]));
	$benefits       = htmlspecialchars(trim($_POST[benefits]));
	$bname          = htmlspecialchars(trim($_POST[bname]));
	$bemail         = htmlspecialchars(trim($_POST[bemail]));
	$bphone         = htmlspecialchars(trim($_POST[bphone]));
	$baddress       = htmlspecialchars(trim($_POST[baddress]));
	$licensenumber  = htmlspecialchars(trim($_POST[licensenumber]));
	$licenseissue   = htmlspecialchars(trim($_POST[licenseissue]));
	$licensephone   = htmlspecialchars(trim($_POST[licensephone]));
	$ref_1_cpname   = htmlspecialchars(trim($_POST[ref_1_cpname]));
	$ref_2_cpname   = htmlspecialchars(trim($_POST[ref_2_cpname]));
	$ref_3_cpname   = htmlspecialchars(trim($_POST[ref_3_cpname]));
	$ref_1_ctname   = htmlspecialchars(trim($_POST[ref_1_ctname]));
	$ref_2_ctname   = htmlspecialchars(trim($_POST[ref_2_ctname]));
	$ref_3_ctname   = htmlspecialchars(trim($_POST[ref_3_ctname]));
	$ref_1_phone    = htmlspecialchars(trim($_POST[ref_1_phone]));
	$ref_2_phone    = htmlspecialchars(trim($_POST[ref_2_phone]));
	$ref_3_phone    = htmlspecialchars(trim($_POST[ref_3_phone]));
	$ref_1_email    = htmlspecialchars(trim($_POST[ref_1_email]));
	$ref_2_email    = htmlspecialchars(trim($_POST[ref_2_email]));
	$ref_3_email    = htmlspecialchars(trim($_POST[ref_3_email]));
	$ref_1_relationship    = htmlspecialchars(trim($_POST[ref_1_relationship]));
	$ref_2_relationship    = htmlspecialchars(trim($_POST[ref_2_relationship]));
	$ref_3_relationship    = htmlspecialchars(trim($_POST[ref_3_relationship]));

	if($_POST[password]){
	  $pwd =  "`ep_pword`='$password' ,";
	}


    $sql = "UPDATE ".$db_prefix."employer 
	                 SET 
					 ".$pwd."
					 `ep_servicecode`='".$servicecode."',
					 `ep_copname` = '".$companyname."', 
					 `ep_fname` = '".$firstname."',
					 `ep_lname` =  '".$lastname."',
					 `ep_title` = '".$jobtitle."',
					 `ep_address1` ='".$address."', 
					 `ep_industry` = '".$industry."',
					 `ep_copsize` = '".$companysize."',
					 `ep_skype` ='".$skype."',
					 `ep_country` = '".$locountry."',
					 `ep_state` = '".$lostate."',
					 `ep_city` = '".$locity."',
					 `ep_zip` = '".$lozip."',
					 `ep_phone` = '".$phone."',
					 `ep_fax` = '".$fax."',
					 `ep_email` ='".$email."',
					 `ep_website` ='".$companyurl."',
					 `ep_howus` ='".$howus."',
					 `ep_newsmailist` ='".$newsmailist."',
					 `ep_bname` = '".$bname."', 
					 `ep_bemail` ='".$bemail."',
					 `ep_bphone` ='".$bphone."', 
					 `ep_baddress` = '".$baddress."',
					 `ep_ERaccount` = '".$eraccount."',
					 `ep_CompCulture` = '".$culture."',
					 `ep_CompBenefits` ='".$benefits."',
					 `ep_license` ='".$licensenumber."',
					 `ep_license_Issue` ='".$licenseissue."', 
					 `ep_license_office` ='".$licensephone."',
					 `ep_pr1_cpname` ='".$ref_1_cpname."',
					 `ep_pr1_ctname` ='".$ref_1_ctname."',
					 `ep_pr1_phone` ='".$ref_1_phone."',
					 `ep_pr1_email` = '".$ref_1_email."',
					 `ep_pr1_relationship` = '".$ref_1_relationship."',
					 `ep_pr2_cpname` ='".$ref_2_cpname."', 
					 `ep_pr2_ctname` = '".$ref_2_ctname."', 
					 `ep_pr2_phone` ='".$ref_2_phone."', 
					 `ep_pr2_email` ='".$ref_2_email."',
					 `ep_pr2_relationship` ='".$ref_2_relationship."',
					 `ep_pr3_cpname` = '".$ref_3_cpname."',
					 `ep_pr3_ctname` = '".$ref_3_ctname."',
					 `ep_pr3_phone` ='".$ref_3_phone."',
					 `ep_pr3_email` = '".$ref_3_email."',
					 `ep_pr3_relationship` = '".$ref_3_relationship."'
                   
					WHERE ep_id= '".$_POST[id]."'";


	$DB->query($sql);
    redirect("./employer.php?action=list&offset=".$offset,"<font color=red>Modified Successfully!</font>");
}
cpfooter();
?>